﻿var aaa = "#fUI/UIWindow2.img/QuestAlarm/BtQ/normal/0#";
//"#fUI/UIWindow.img/PvP/Scroll/enabled/next2#";
var head = "#fUI/UIWindow2.img/Quest/quest_info/summary_icon/summary#\r\n";

var itemlist = new Array(
Array(2431965, 10000), //默认伤害皮肤
Array(2433104, 10000),
Array(2431967, 10000), //克里蒂亚斯伤害皮肤
Array(2432131, 10000), //组队任务伤害皮肤
Array(2432603, 10000),
Array(2433106, 10000),
Array(2432207, 10000), //射手村俱乐部伤害皮肤
Array(2432354, 10000), //圣诞快乐伤害皮肤
Array(2433710, 10000),
Array(2433199, 10000),
Array(2432479, 10000), //桃乐丝的伤害皮肤
Array(2433105, 10000),
Array(2433107, 10000),
Array(2433132, 10000),
Array(2432640, 10000), //回忆伤害皮肤
Array(2432710, 10000), //花蘑菇伤害皮肤
Array(2432836, 10000), //王冠伤害皮肤
Array(2432973, 10000), //灰白伤害皮肤
Array(2433063, 10000), //Star Planet伤害皮肤
Array(2433178, 10000), //毛骨悚然伤害皮肤
Array(2433456, 10000), //韩文日伤害皮肤
Array(2433631, 10000), //?????
Array(2433655, 10000), //?????  
Array(2433715, 10000), //七彩伤害皮肤                    
Array(2433981, 10000), // 更改为品克缤伤害皮肤                  
Array(2432591, 10000), //樱吹雪伤害皮肤                    
Array(2432695, 10000), //金灿灿伤害皮肤                  
Array(2432748, 10000), //血色伤害皮肤                   
Array(2432749, 10000), //僵尸伤害皮肤                   
Array(2432803, 10000), //浓姬伤害皮肤（30天） 
Array(2432804, 10000), //紫色妖姬伤害皮肤                
Array(2433112, 10000), //卧虎藏龙伤害皮肤
Array(2433558, 10000),                   
Array(2433113, 10000), //冰淇淋伤害皮肤                  
Array(2433038, 10000), //粉笔效果伤害皮肤                     
Array(2433197, 10000), //蘑菇公主伤害皮肤                     
Array(2433182, 10000), //万圣节南瓜伤害皮肤                    
Array(2433183, 10000), //万圣节幽灵伤害皮肤                  
Array(2433184, 10000), //女巫伤害皮肤                    
Array(2433362, 10000), //夜空伤害皮肤                    
Array(2433587, 10000), //羊咩咩伤害皮肤                    
Array(2433588, 10000), //烟花伤害皮肤                    
Array(2433572, 10000), //娇艳玫瑰伤害皮肤                  
Array(2433571, 10000), //彩色涂鸦伤害皮肤           
Array(2433570, 10000), //恋爱季节伤害皮肤                    
Array(2433569, 10000), //爆裂之石伤害皮肤                     
Array(2433568, 10000), //蜜桃甜心伤害皮肤                     
// Array(2433709, 10000), //兔年糕伤害皮肤
Array(2434081, 10000),                     
Array(2433777, 10000), //黑色天堂伤害皮肤
Array(2433775, 10000), //奥尔卡伤害皮肤
Array(2433776, 10000), //斯乌伤害皮肤
Array(2433828, 10000),// 白色天堂太阳伤害皮肤
Array(2433829, 10000),// 白色天堂暴雨伤害皮肤
Array(2433830, 10000),// 白色天堂彩虹伤害皮肤
Array(2433831, 10000),// 白色天堂雪花伤害皮肤
Array(2433832, 10000),// 白色天堂闪电伤害皮肤
Array(2433833, 10000),// 白色天堂狂风伤害皮肤
Array(2433883, 10000) //绿色地球伤害皮肤
//Array(2434004, 10000) //小筱傷害字型

        );

var status = 0;
var typed = 0;
var rmb = 0;
var seld;

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.dispose();
            return;
        }
        if (mode == 1)
            status++;
        else
            status--;
        if (status == 0) {
            var selStr = head + "#d#e欢迎使用点券购买物品,请选择您想要的：#n#k\r\n";
            selStr += "#d您当前拥有点券：  #r" + cm.getNX(1) + "#k #d点\r\n#您当前拥有抵用券：  #r" + cm.getNX(2) + "#d#k 点#k\r\n\r\n";
            selStr += "- #e装备#n\r\n";
            for (var i in itemlist) {
                selStr += "#L" + i + "##b" + aaa + "购买 #r#z" + itemlist[i][0] + "##k 需" + (i >= 2 && i <=4 ? "" : "要 ") + "#r" + itemlist[i][1] + "#k 点券#l\r\n";
            }
            selStr += " \r\n\r\n";
            cm.sendSimple(selStr);
        } else if (status == 1) {
			seld = selection;
			cm.sendYesNo(head + "确定购买一个 #r#z" + itemlist[seld][0] + "##k吗？ 将会使用掉您 #r" + itemlist[seld][1] + "点券. ");
        } else if (status == 2) {
			//var nx1 = cm.getNX(1);
			//var nx2 = cm.getNX(2);
			//if (nx1 < itemlist[seld][1] && nx2 < itemlist[seld][1] || cm.getSpace(2) < 1) {
			if(cm.getPlayer().getCSPoints(1) <  itemlist[seld][1] || cm.getSpace(2) < 1){	
				cm.sendOk(head + "购买失败：\r\n\r\n#r1). 当前点卷未达到条件.\r\n2). 背包装备栏位已满,请清理.");
			} else {
				//cm.gainNX(nx2 < itemlist[seld][1] ? 1 : 2, -itemlist[seld][1]);
				cm.gainNX(1,-itemlist[seld][1]);
				cm.gainItem(itemlist[seld][0], 1);
				cm.sendOk(head + "恭喜您成功购买#z" + itemlist[seld][0] + "#.");
				cm.getMap().startMapEffect("恭喜玩家 " + cm.getChar().getName() + " 成功购买" + cm.getItemName(itemlist[seld][0]) + "一个。", 5120012);
				cm.worldSpouseMessage(0x15, "『点券商城』 : 恭喜 " + cm.getChar().getName() + " 用点卷购买" + cm.getItemName(itemlist[seld][0]) + "一个.");
			}
			cm.dispose();
        }
    }
}
